package org.jeecg.modules.parameter.biz.controlltr;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.parameter.api.dto.hall.SimHallDto;
import org.jeecg.modules.parameter.api.entity.SimExit;
import org.jeecg.modules.parameter.api.entity.SimHall;
import org.jeecg.modules.parameter.api.entity.SimLine;
import org.jeecg.modules.parameter.api.vo.exit.SimExitVo;
import org.jeecg.modules.parameter.api.vo.hall.SimHallVo;
import org.jeecg.modules.parameter.api.vo.power.SimPowerJsonVo;
import org.jeecg.modules.parameter.biz.service.SimLineService;
import org.jeecg.modules.parameter.biz.service.SimStationExitService;
import org.jeecg.modules.parameter.biz.service.SimStationHallService;
import org.jeecg.modules.parameter.common.api.dto.PatchPO;
import org.jeecg.modules.parameter.common.utils.oConvertUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lsy
 * @date 2024/09/17
 */
@Api(tags = "参数管理-车站-站厅管理")
@RestController
@RequestMapping(value = {"/stationHallInfo"}, produces = {"application/json; charset=utf-8"})
@Slf4j
public class SimStationHallController extends JeecgController<SimHall, SimStationHallService> {

    @Resource
    private SimStationHallService simStationHallService;

    @ApiOperation(value = "按车站ID查询站厅信息", notes = "按车站ID查询站厅信息")
    @PostMapping(value = "/getHallBySataId")
    public Result<List<SimHallVo>> getHallBySataId(@RequestParam(name = "stationId", required = true) String id) {
        List<SimHallVo> simHallVo = oConvertUtils.entityListToModelList(simStationHallService.getHallBySataId(id), SimHallVo.class);
        return Result.ok(simHallVo);
    }

    @ApiOperation(value = "按ID删除车站站厅", notes = "按ID删除车站站厅")
    @DeleteMapping(value = "/delHall")
    public Result<String> delHall(@RequestParam(name = "id", required = true) String id) {
        simStationHallService.removeById(id);
        return Result.ok("删除成功");
    }
    @ApiOperation(value = "按ID查询车站站厅", notes = "按ID查询车站站厅")
    @PostMapping(value = "/queryHallById")
    public Result<SimHallVo> queryHallById(@RequestParam(name = "id", required = true) String id) {

        return Result.ok(oConvertUtils.entityToModel(simStationHallService.getById(id),SimHallVo.class));
    }

    @ApiOperation(value = "添加车站站厅信息", notes = "添加车站站厅信息")
    @PostMapping(value = "/addHall")
    public Result<String> addHall(@RequestBody SimHallDto simHallDto) {
        SimHall simHall = oConvertUtils.entityToModel(simHallDto, SimHall.class);
        simStationHallService.save(simHall);
        return Result.ok("保存成功");
    }


    @ApiOperation(value = "修改车站站厅信息", notes = "修改车站站厅信息")
    @PutMapping(value = "/updateHall")
    public Result<String> updateHall(@RequestBody PatchPO patchPO) {
        simStationHallService.updatePatch(patchPO);
        return Result.OK("更新成功!");
    }

}
